<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>分类新增</title>
    <meta name="referrer" content="no-referrer"/>
    <link th:href="@{/css/bootstrap-3.3.7-dist/css/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap-3.3.7-dist/css/bootstrap-theme.css}" rel="stylesheet">
    <link th:href="@{/css/blog.css}" rel="stylesheet">
    <link th:href="@{/css/adminblog.css}" rel="stylesheet">
    <script type="text/javascript" th:src="@{/js/jquery-3.0.0.js}"></script>
    <script type="text/javascript" th:src="@{/js/jquery-3.0.0.min.js}"></script>
    <script type="text/javascript" th:src="@{/css/bootstrap-3.3.7-dist/js/bootstrap.js}"></script>
    <script type="text/javascript" th:src="@{/css/bootstrap-3.3.7-dist/js/bootstrap.min.js}"></script>
<!--    <script type="text/javascript" th:src="@{/css/bootstrap-3.3.7-dist/js/npm.js}"></script>-->
</head>
<body style="background-color: #F2F2F2">
<div th:replace="admin/adminblog::adminheader"></div>
<nav class="navbar m-padded-tb-mimi m-a-padded">
    <div class="container">
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a th:href="@{/admin/types/input}">发布</a></li>
                <li><a th:href="@{/admin/types}">列表</a></li>
            </ul>
        </div>
    </div>
</nav>
<div>
    <div class="container">
        <form id="form" action="#" method="post" th:object="${type}"  th:action="*{id}==null ? @{/admin/types/save}:@{/admin/types/save/{id}(id=*{id})}">
            <div>
                <input type="hidden" name="id" th:value="*{id}">
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-1 control-label" style="font-size: 20px;text-align: center" for="name">名称</label>
                    <div class="col-sm-11">
                        <input type="text" class="form-control" id="name" aria-describedby="basic-addon3" name="name" th:value="*{name}" placeholder="分类名称">
                    </div>
                </div>
            </div>
            <!--/*/
            <div class="alert alert-success alert-dismissible" role="alert" th:if="${#fields.hasErrors('name')}">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <strong>提示：</strong><span th:errors="*{name}">>恭喜，操作成功！</span>
            </div>
            /*/-->
            <div class="form-group">
                <div style="float: right">
                    <button type="button" class="btn btn-default" onclick="window.history.go(-1)">返回</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div><br>
<div th:replace="admin/adminblog::adminfooter"></div>
<script type="text/javascript">
    $('.dropdown-toggle').dropdown()

    var $name = $("#name")
    $(document).ready(function () {
        $("#form").submit(function () {
            if (name()){
                return true
            }else {
                return false
            }
        })
    })

    function name() {
        if ($name.val() == ""){
            window.alert("分类名称不能为空")
            return false
        }
        return true
    }
</script>

<script type="text/javascript">
    $("#newBlog-container").load(/*[[@{/footer/newBlog}]]*/"/footer/newBlog")
</script>
</body>
</html>